package com.bestcem.xm.om.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.ToString;

/**
 * 发送状态
 *
 * @author zhangfeng <feng.zhang@idiaoyan.com>
 * @version v1.0
 * @date 2021/11/8 16:53
 */
@Getter
@ToString
public enum SendStatusEnum {
    /**
     * 待发送
     */
    TO_SEND("待发送", 0),

    /**
     * 已发送
     */
    SENDING("已发送", 1),

    /**
     * 发送成功
     */
    SUCCESS("发送成功", 2),

    /**
     * 发送失败
     */
    FAILED("发送失败", 3);

    private final String name;

    private final Integer index;

    SendStatusEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static String getNameByIndex(Integer index) {
        if (index == null) {
            return null;
        }
        for (SendStatusEnum channel : values()) {
            if (channel.getIndex().equals(index)) {
                return channel.getName();
            }
        }
        return StrUtil.EMPTY;
    }
}
